class Banana(Dataset):
    def __init__(self, is_train=True):
        self.data = []
        base_path = r'/data/banana-detection'
        if is_train:
            self.img_path=os.path.join(os.path.join(base_path,'bananas_train','images'))
            self.data=pd.read_csv(os.path.join(base_path,'bananas_train','label.csv'))
        else:
            self.img_path=os.path.join(os.path.join(base_path,'bananas_val','images'))
            self.data = pd.read_csv(os.path.join(base_path,'bananas_val','label.csv'))
    def __len__(self):
        return len(self.data)
    def __getitem__(self, item):
        img = cv2.imread(os.path.join(self.img_path,self.data.loc[item]['img_name']))
        img_shape = img.shape
        target_size = 448
        aug = transforms.Compose([transforms.ToTensor(),transforms.Resize(target_size)])
        img = aug(img)

        labels = [
            self.data.loc[item]['label'],
            (self.data.loc[item]['xmin'] + self.data.loc[item]['xmax'])/2 / img_shape[1],# x
            (self.data.loc[item]['ymin'] + self.data.loc[item]['ymax'])/2 / img_shape[0],# y
            (self.data.loc[item]['xmax'] -self.data.loc[item]['xmin']) / img_shape[1],# w
            (self.data.loc[item]['ymax'] -self.data.loc[item]['ymin']) / img_shape[0],# h
        ]
        # 使用convert_bbox2labels()函数把bbox转化成label
        labels=convert_bbox2labels(bbox=labels,
NUM_BBOX=2,
CLASSES=['banana']+['cls_name']*19)
        return img, labels 
